import { createStore } from 'vuex'
import router from '../router'
import {reactive} from "vue";

const state = {
    keepAlive: [],
    statuses: {}
}

const modules = {

}

const getters = {
    getStatus: (state) => (key) => {
        return state.statuses[key];
    }
}

const mutations = {
    keepAlive (state, name) {
        !state.keepAlive.includes(name) && state.keepAlive.push(name)
        console.log(state.keepAlive)
    },
    noKeepAlive (state, name) {
        const index = state.keepAlive.indexOf(name)
        index !== -1 && state.keepAlive.splice(index, 1)
    },
    setStatus(state, {key, value}) {
        console.log(value)
        state.statuses[key] = value
    }
}

export default createStore({
    state,
    getters,
    modules,
    mutations
})